package com.ygqh.baby.token;

import com.ygqh.baby.cache.CacheCreator;
import com.ygqh.baby.http.YgRequestExecutor;

/**
 * Token的创建
* @ClassName: TokenCreator 
* @author (guohao)  
* @date 2018年6月28日 下午1:28:47 
* @version V1.0
 */
public abstract class TokenCreator implements CacheCreator<Token> {

	/**
	 * 缓存KEY前缀
	 */
	public final static String CACHEKEY_PREFIX = "token_";

	protected final YgRequestExecutor requestExecutor;

	public TokenCreator() {
		this.requestExecutor = new YgRequestExecutor();
	}

	/**
	 * 缓存key:附加key前缀
	 *
	 * @return
	 */
	@Override
	public String key() {
		return String.format("%s%s_%s", CACHEKEY_PREFIX, name(), uniqueid());
	}

	/**
	 * 返回缓存类型命名，如mp_token
	 *
	 * @return
	 */
	public abstract String name();

	/**
	 * 返回缓存唯一标识，如appid
	 *
	 * @return
	 */
	public abstract String uniqueid();
}
